package com.jming.yygh.oss.controller;

import com.jming.yygh.common.result.Result;
import com.jming.yygh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author jming
 * @version 0.0.1
 * @date 2021/05/11
 */
@Api(tags = "阿里云oss对象存储接口")
@RestController
@RequestMapping("/api/oss/file")
public class FileApiController {

    @Resource
    FileService fileService;

    @ApiOperation(value = "文件上传接口")
    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file) {

        // 获取上传的文件
        String url = fileService.upload(file);
        return Result.ok(url);
    }
}
